#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->label->setText("空");
    ui->lineEdit->setPlaceholderText("请输入密码");
    ui->lineEdit_2->setPlaceholderText("再次输入密码");
    ui->lineEdit->setClearButtonEnabled(true);
    ui->lineEdit_2->setClearButtonEnabled(true);
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    QString s1 = ui->lineEdit->text();
    QString s2 = ui->lineEdit_2->text();
    if(s1.isEmpty()||s2.isEmpty())
    {
        ui->label->setText("空");
    }
    else if(s1!=s2)
    {
        ui->label->setText( "不一致");
    }
    else
    {
        ui->label->setText("一样");
    }
}

void Widget::on_checkBox_stateChanged(int arg1)
{
    if(arg1==2)
    {
        ui->lineEdit->setEchoMode(QLineEdit::Normal);
        ui->lineEdit_2->setEchoMode(QLineEdit::Normal);
    }
    else
    {
        ui->lineEdit->setEchoMode(QLineEdit::Password);
        ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    }
}
